import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';

/// 关于我们页面
class RegardsPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _RegardskeyPage();
  }
}

class _RegardskeyPage extends State<RegardsPage> {
  String _versionNare = "";

  Future<bool> _onWillPop() async {
    // PersonalPageState.globalKeythere.currentState?.reloadData();
    return true; // 返回true表示允许返回，返回false表示阻止返回
  }

  // 获取版本号 - 私有属性
  Future _getVersion() async {
    PackageInfo info = await PackageInfo.fromPlatform();
    var version = info.version;
    _versionNare = "v $version";
    setState(() {});
  }

  @override
  void initState() {
    super.initState();
    _getVersion();
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: _onWillPop,
      child: Scaffold(
        backgroundColor: Color(0xFFfafafa),
        appBar: _buildTitleBar(context),
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.all(16.0), // 设置内边距
            child: Center( // 将 Column 包裹在 Center 中
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center, // 垂直居中
                children: [
                  // 本地图片 90x90
                  Image.asset(
                    'assets/app_img/ic_launch.png', // 替换为你的图片路径
                    width: 90,
                    height: 90,
                  ),
                  SizedBox(height: 10), // 间距 10
                  // 文字 智慧视联
                  Text(
                    '智慧视联',
                    style: TextStyle(
                      fontSize: 24,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  SizedBox(height: 10), // 间距 10
                  // 文字 v 1.0.0
                  Text(
                    _versionNare,
                    style: TextStyle(
                      fontSize: 16,
                      color: Colors.grey,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

  AppBar _buildTitleBar(BuildContext context) {
    return AppBar(
      toolbarHeight: 60,
      leading: IconButton(
        icon: Icon(Icons.arrow_back_ios), // 使用没有横线的返回箭头图标
        onPressed: () {
          _onWillPop();
          // 返回操作
          Navigator.of(context).pop();
        },
      ),
      backgroundColor: Color(0xFFffffff),
      automaticallyImplyLeading: false, // 禁用自动生成的返回按钮
      title: Text(
        "关于我们",
        style: TextStyle(
          fontSize: 17,
          fontFamily: "PingFang SC",
          fontWeight: FontWeight.w600,
        ),
      ),
      centerTitle: true,
    );
  }

// 账户安全

// 其他
}
